<html>
  <head><title>document loading</title></head>
  <body>
    <script>
      var bear = document.createElement('video');
      var isMetadataLoaded = false;
      var isPlaying = false;

      var autoplay = (window.location.href.indexOf("autoplay") > 0);
      if (autoplay) {
        bear.autoplay = true;
      }

      bear.onerror = function() { document.title = 'error'; }
      bear.onloadeddata = function() {
        document.title = 'loaded';

        if (autoplay) {
          // No events are generated if autoplay's been denied, so use a
          // 0.2s timeout to detect and report the denial.
          window.setTimeout(function() {
            if (!isPlaying)
              document.title = 'blocked';
          }, 200);
        }
      }
      bear.onloadedmetadata = function() { isMetadataLoaded = true; }
      bear.onpause = function () { isPlaying = false; }
      bear.onplay = function() {
        isPlaying = true;
        document.title = 'playing';
      }
      bear.onstalled = function() { document.title = 'stalled'; }
      bear.src = 'bear-vp8a.webm';

      // Programatically set the title, to provide an externally-visible
      // indication that the page's scripts have executed.
      document.title = 'initial title';
    </script>
  </body>
</html>
